package com.ruoyi.service.impl;

import java.util.List;

import com.ruoyi.domain.Course;
import com.ruoyi.domain.CourseHobby;
import com.ruoyi.domain.CourseStudyExperience;
import com.ruoyi.mapper.CourseMapper;
import com.ruoyi.service.ICourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2024-04-22
 */
@Service
public class CourseServiceImpl implements ICourseService {
    @Autowired
    private CourseMapper courseMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param courseId 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public Course selectCourseByCourseId(Long courseId) {
        return courseMapper.selectCourseByCourseId(courseId);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param course 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<Course> selectCourseList(Course course) {
        return courseMapper.selectCourseList(course);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param course 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertCourse(Course course) {
        return courseMapper.insertCourse(course);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param course 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateCourse(Course course) {
        return courseMapper.updateCourse(course);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param courseIds 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteCourseByCourseIds(Long[] courseIds) {
        return courseMapper.deleteCourseByCourseIds(courseIds);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param courseId 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteCourseByCourseId(Long courseId) {
        return courseMapper.deleteCourseByCourseId(courseId);
    }

    @Override
    public Double selectTeachAvg(String name) {
        return courseMapper.selectTeachAvg(name);
    }

    @Override
    public Integer selectCourseIdByCourseName(String courseName) {
        return courseMapper.selectCourseIdByCourseName(courseName);
    }

    @Override
    public List<Course> getAllBySelect(Long studentId, String courseName, String teachName) {
        if (courseName != null){
            courseName = "%"+courseName + "%";
        }
        if (teachName != null){
            teachName = "%"+teachName + "%";
        }

        return courseMapper.getAllBySelect(studentId, courseName, teachName);
    }

    @Override
    public List<Course> getAllBySelected(Long studentId, String courseName, String teachName) {
        if (courseName != null){
            courseName = "%"+courseName + "%";
        }
        if (teachName != null){
            teachName = "%"+teachName + "%";
        }

        return courseMapper.getAllBySelected(studentId, courseName, teachName);
    }

    @Override
    public List<Course> getAddedCourse(String courseName, String teachName) {
        if (courseName != null){
            courseName = "%"+courseName + "%";
        }
        if (teachName != null){
            teachName = "%"+teachName + "%";
        }
        return courseMapper.getAddedCourse(courseName, teachName);
    }

    @Override
    public void unAddedCourse(Long courseId) {
        courseMapper.unAddedCourse(courseId);
    }

    @Override
    public List<Course> getUnAddedCourse(String courseName, String teachName) {
        if (courseName != null){
            courseName = "%"+courseName + "%";
        }
        if (teachName != null){
            teachName = "%"+teachName + "%";
        }
        return courseMapper.getUnAddedCourse(courseName, teachName);
    }

    @Override
    public void addedCourse(Long courseId) {
        courseMapper.addedCourse(courseId);
    }

    @Override
    public List<Course> getRecommCourse(Long studentId, String hobby, String studyExperience,String courseName,String teachName) {
        if (courseName != null){
            courseName = "%"+courseName + "%";
        }
        if (teachName != null){
            teachName = "%"+teachName + "%";
        }
        return courseMapper.getRecommCourse(studentId, hobby, studyExperience, courseName, teachName);
    }

    @Override
    public List<CourseHobby> getHobbyType() {
        return courseMapper.getHobbyType();
    }

    @Override
    public List<CourseStudyExperience> getStudyExperienceType() {
        return courseMapper.getStudyExperienceType();
    }
}
